import { ByteStream } from "../tools/ByteStream";
import { GetByteStream } from "../tools/encryp";
import { DWORD, BYTE, WORD, LONG, TCHAR, BaseProto } from "./base.proto";
import CommConst from "../const/CommConst";
//Request///////////////////////////////////////////

/**请求钱包登录*/
export class Req_GP_Logon
{
    dwUserID:number;					//DWORD	用户 UserID
    szToken:string;			            //TCHAR	TOKEN [TOKEN_LEN]

    decode(UserID:number,token:string)
    {
        let bStream:ByteStream = GetByteStream.getStream(CommConst.Req_LOGIN,0,40);

        this.dwUserID = UserID;
        this.szToken = token;

        bStream.writeUint(this.dwUserID);
        bStream.writeString(this.szToken,CommConst.TOKEN_LEN);
        
        return bStream.buffer;
    }
}


//     "badge": 3,
//     "boatTypes": [
//         0
//     ],
//     "camp": 0,
//     "crystal": 173,
//     "finishTime": [],
//     "icon": 0,
//     "id": 200009,
//     "name": "333",
//     "sign": 1,
//     "signStatus": 0,
//     "successNum": 163,
//     "userId": 20009,
//     "ustd": 0,
//     "vipCanUseNum": 0,
//     "vipTime": 0
// }
//用户信息
export class PlayerInfo
{
	wBadge          :number;				//WORD         勋章数量 
	cbBoatTypes     :number[];				//BYTE         游戏类型
	wCamp           :number;				//WORD         
    
    decode(byteStream:ByteStream)
    {
        this.wBadge	= byteStream.readUsort();
        this.cbBoatTypes = [];
        let opType0 = byteStream.readByte();
        let opType1 = byteStream.readByte();
        this.cbBoatTypes.push(opType0);
        this.cbBoatTypes.push(opType1);
        this.wCamp = byteStream.readUsort();

    }
    parse(buf:ArrayBuffer)
    {
        let byteStream = new ByteStream(buf);
        this.wBadge	= byteStream.readUsort();
        this.cbBoatTypes = [];
        let opType0 = byteStream.readByte();
        let opType1 = byteStream.readByte();
        this.cbBoatTypes.push(opType0);
        this.cbBoatTypes.push(opType1);
        this.wCamp = byteStream.readUsort();
    }
    
}

/**钱包登陆成功*/
export class Resp_GP_LogonSuccess
{  
    dwUserID:number;					// DWORD 用户ID
    wResult:number;						// WORD 结果
    cbPlayerInfo:PlayerInfo;			// PlayerInfo  用户信息

    parse(buf:ArrayBuffer)//136
    {
        let byteStream = new ByteStream(buf);
        this.dwUserID       = byteStream.readUint();		
        this.wResult       = byteStream.readUsort();
        this.cbPlayerInfo = new PlayerInfo()
        this.cbPlayerInfo.decode(byteStream)

        
    }
}
